
//
// Created by wyh on 2025-07-20 20:24.
//

#include <iostream>
#include <string>
#include "json/json.h"
#include "json/parser.h"

using namespace std;
using namespace wyh::json;

int main(int argc, char **argv)
{
    Json v1;
    Json v2 = true;
    Json v3 = 123;
    Json v4 = 1.23;
    Json v5 = "hello world";

//    cout << v1.str() << endl;
//    cout << v2.str() << endl;
//    cout << v3.str() << endl;
//    cout << v4.str() << endl;
//    cout << v5.str() << endl;

    cout << v1 << endl;
    cout << v2 << endl;
    cout << v3 << endl;
    cout << v4 << endl;
    cout << v5 << endl;

//    bool b = v2.as_bool();
//    int i = v3.as_int();
//    double f = v4.as_double();
//    string s = v5.as_string();

    bool b = v2;
    int i = v3;
    double f = v4;
    string s = v5;

    cout << "bool:" << b << endl;
    cout << "int:" << i << endl;
    cout << "double:" << f << endl;
    cout << "string:" << s << endl;

    Json v6 = "hello world";
    v6 = 123;
    cout << v6 << endl;

    cout << "------------------------------" << endl;

    Json v7;
    v7.append(true);
    v7.append(123);
    v7.append(1.25);
    v7.append("hello world");
    v7.append(Json());

    cout << v7 << endl;

    cout << "------------------------------" << endl;
    bool b1 = v7.get(0);
    int i1 = v7[1];
    string s1 = v7[3];

    cout << "b1:" << b1 << endl;
    cout << "i1:" << i1 << endl;
    cout << "s1:" << s1 << endl;

    v7.remove(3);
    cout << v7 << endl;

    cout << "------------------------------" << endl;

    for (auto it = v7.begin(); it != v7.end(); ++it)
    {
        cout << (*it) << endl;
    }

    cout << "------------------------------" << endl;
    Json v8;
    v8["name"] = "jack";
    v8["age"] = 18;
    v8["gender"] = "male";
    cout << v8 << endl;

    string name = v8["name"];
    cout << "name: " << name << endl;

    int age = v8["age"];
    cout << "age: " << age << endl;

    v8.remove("gender");
    v8["wordk"] = "c++";
    cout << v8 << endl;

    cout << "------------------------------" << endl;
    Json v9 = "hello world";
    Json v10 = v9;
    v9.clear();

    cout << v9 << endl;
    cout << v10 << endl;

    cout << "------------------------------" << endl;

    string str = "[1,2,3,null,true,\"hello world\",{\"name\":\"jack\",\"age\":\"18\"}]";
    Json v ;
    v.parse(str.c_str(),str.size());
    cout << v << endl;
    cout << "------------------------------" << endl;

    Json v11 ;
    v11.parse("./../test.json");
    cout << v11 << endl;
    cout << "------------------------------" << endl;

    Json v12 = "hello world";
    Json v13 = move(v12);

    cout <<v12<<endl;
    cout<<v13<<endl;

    cout << "------------------------------" << endl;



    return 0;
}
